package com.des1gn.serviceb.service.impl;

import com.des1gn.serviceb.aspect.EnableTrans;
import com.des1gn.serviceb.dao.BMapper;
import com.des1gn.serviceb.entity.B;
import com.des1gn.serviceb.entity.BVo;
import com.des1gn.serviceb.service.TestService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName TestServiceImpl
 * @Description TODO
 * @Author Des1gn
 * @Date 2021/12/15 14:07
 * @Version 1.0
 **/
@Service
@RequiredArgsConstructor
public class TestServiceImpl implements TestService {

    private final BMapper bMapper;

    @Override
    @EnableTrans
    public List<BVo> getB() {
        List<B> first = bMapper.getFirst();
        List<BVo> result = new ArrayList<>();
        first.forEach(i->{
            BVo bVo = new BVo();
            BeanUtils.copyProperties(i,bVo);
            result.add(bVo);
        });
        return result;
    }
}
